package org.springframework.validation.util;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ValidationRulesUtils {
	
	private static Log log = LogFactory.getLog(ValidationRulesUtils.class);
	
	public static final String EMAIL_PATTERN = "^\\w+([_\\.-]\\w+)*@(\\w+([_\\.-]\\w+)*([.]\\w+)+)";
	public static final String ALPHABETIC_STRICT_PATTERN = "[A-Za-z]*";
	public static final String NUMERIC_PATTERN = "[0-9]*";
	public static final String DECIMAL_PATTERN = "[0-9]*\\.?[0-9]*";
	public static final String ALPHANUMERIC_STRICT_PATTERN = "[A-Za-z0-9]*";
	public static final String URL_PATTERN = "(http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&amp;:/~\\+#]*[\\w\\-\\@?^=%&amp;/~\\+#])?";
	public static final int MINDIGITSINPHONE = 10; //minimum number of digits in a valid fax or phone number
	public static final int MAXDIGITSINPHONE = 14; //maximum number of digits in a valid fax or phone number
		
	public static int getLength(Object object) {
		return String.valueOf(object).length();
	}
	
	public static boolean isEmpty(Object object) {
		return object == null || String.valueOf(object).trim().length() < 1;
	}
}
